package member2;

import java.awt.Color;
import java.text.SimpleDateFormat;
import java.util.ArrayList;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;

public class Output extends JPanel {
	private JScrollPane scrollPane;
	private JTextArea result;
	private JLabel lblNewLabel;
	ArrayList<Data> list;

	/**
	 * Create the panel.
	 */
	public Output(ArrayList list) {
		this.list=list;
		setBackground(Color.BLACK);
		setLayout(null);
		add(getScrollPane());
		prn();

	}

	private JScrollPane getScrollPane() {
		if (scrollPane == null) {
			scrollPane = new JScrollPane();
			scrollPane.setBounds(12, 10, 426, 280);
			scrollPane.setViewportView(getResult());
			scrollPane.setColumnHeaderView(getLblNewLabel());
		}
		return scrollPane;
	}
	private JTextArea getResult() {
		if (result == null) {
			result = new JTextArea();
		}
		return result;
	}
	private JLabel getLblNewLabel() {
		if (lblNewLabel == null) {
			lblNewLabel = new JLabel("이름          주소          연락처          이메일          나이      입사일");
			lblNewLabel.setBackground(Color.ORANGE);
		}
		return lblNewLabel;
	}
	public void prn(){
		result.setText("전체 데이터 건수 : " + list.size());
		result.append("\n====================================\n");
		for(int i=0; i<list.size();i++){
			Data d = list.get(i);
			SimpleDateFormat sdf = new SimpleDateFormat("yy-MM-dd");
			String temp="";
			
			result.append(d.getIrum() + "\t");
			result.append(d.getAddress() + "\t");
			result.append(d.getNumber() + "\t");
			result.append(d.getEmail() + "\t");
			result.append(d.getAge() + "\t");
			result.append(sdf.format(d.getNal()) + "\t");
			
			result.append("\n");
		}		
	}
}
